/**
 * AUTHOR: Zhou Yu <pepsior@163.com>
 *
 * COPYRIGHT(C) 2011 Zhou Yu. ALL RIGHTS RESERVED.
 */
#pragma once
#ifndef XL_VERSION_H_INCLUDED
#define XL_VERSION_H_INCLUDED

/* Version */
typedef struct xl_version
{
    unsigned short major;
    unsigned short minor;
    unsigned short internal;
    unsigned short patch;
}xl_version_t;

/* Initialize version. */
__inline static void xl_version_init(xl_version_t *version, 
    unsigned short major, unsigned short minor, unsigned short internal, 
    unsigned short patch)
{
    version->major = major;
    version->minor = minor;
    version->internal = internal;
    version->patch = patch;
}

/* Check the equality of versions. */
__inline static BOOL xl_version_equal(
    const xl_version_t *version1, const xl_version_t *version2)
{
    return version1->major == version2->major 
        && version1->minor == version2->minor
        && version1->internal == version2->internal
        && version1->patch == version2->patch;
}

/* Get the major part of version. */
__inline static unsigned short xl_version_get_major(const xl_version_t *version)
{
    return version->major;
}

/* Get the minor part of version. */
__inline static unsigned short xl_version_get_minor(const xl_version_t *version)
{
    return version->minor;
}

/* Get the internal part of version. */
__inline static unsigned short xl_version_get_internal(const xl_version_t *version)
{
    return version->internal;
}

/* Get the patch part of version. */
__inline static unsigned short xl_version_get_patch(const xl_version_t *version)
{
    return version->patch;
}

#endif      /* #ifndef XL_VERSION_H_INCLUDED */

